package com.lambo.maven.core.utils.superHttp;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.lambo.maven.core.utils.superHttp.core.ProxyHostsMatcher;
import com.lambo.maven.core.utils.superHttp.utils.SHttpDefault;

public class SHttpSwitch {
    
    private static Logger logger = LoggerFactory.getLogger(SHttpSwitch.class);
    
    public static SHttp getByUrl(String url) {
        try {

            if(ProxyHostsMatcher.useProxy(url)) {
                // 外网请求
                logger.info("外网：" + url);
                return SHttpDefault.getSock5();
            } else {
                // 内网请求
                logger.info("内网：" + url);
                return SHttpDefault.getDefault();
            }
        } catch (RuntimeException e) {
            logger.info("地址：" + url + "无法匹配");
            throw e;
        }
    }
}
